<template>
	<view class="MarketBuy plr-16">
		<view class="item flex-center-sb" v-for="item in list" :key="item.id" @click="toSell(item)">
			<view>
				<view class="price">{{ item.price }}</view>
				<view class="flex-center">
					<text class="font-size-10 font-color-666">支付钱包：</text>
					<view class="font-size-10 font-color-666 plr-3 br-4" style="background-color: #EEEEEE">
					    {{ item.pay_way | formatPayName }}
					</view>
				</view>
			</view>
			<view class="flex-center">
				<text class="font-color-999 font-size-12 mr-4" v-if="item.order_status==7">交易中</text>
				<w-icon name="arrow-right-mini" size="12"></w-icon>
			</view>
		</view>
		<w-loading style="padding: 32rpx 0" :type="loadingType" emptyType="search" emptyTop="60"></w-loading>
		<view class="fix-btn bg-color-white">
			<w-button style="border-radius: 25px;" @click="$u.route('/pages/market/submitBegBuy',{id:product.id})">发起求购</w-button>
			<u-status-bar></u-status-bar>
		</view>
	</view>
</template>

<script> 
	export default {
		name:'MarketBuy',
		props: {
			product: {
				type: Object,
				default: () => ({})
			},
			list: {
				type: Array,
				default: () => []
			},
			loadingType: {
				type: String,
				default: 'more'
			}
		},
		filters: {
		    formatPayName(v) {
		        let map = {
		            huifu: "A",
		            yibao: "易",
		        };
		        return map[v];
		    },
		},
		methods: {
			toSell(item) {
				if (item.order_status==7) {
					return uni.showToast({
						icon: 'none',
						title: "正在交易中..."
					})
				}
				if (item.user_info.id==this.userInfo.id) {
					return uni.showToast({
						icon: 'none',
						title: "不能出售自己发布的求购"
					})
				}
				if (!this.product.is_has) {
					return uni.showToast({
						icon: 'none',
						title: "当前未持有该藏品"
					})
				}
				uni.navigateTo({
					url: `/pages/market/sellBegBuy?buy_id=${item.id}&collection_id=${this.product.id}&pay_way=${item.pay_way}&number=1`
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.MarketBuy {
		>.item{
			padding: 26rpx 0;
			border-bottom: 2rpx solid #eee;
			
			.price {
				font-size: 40rpx;
				color: #000;
				font-weight: bold;
				&:before{
					content: '¥';
					font-size: 32rpx;
					margin-right: 2rpx;
				}
			}
		}
		.fix-btn {
			width: 100%;
			padding: 20rpx 32rpx;
			position: fixed;
			left: 0;
			bottom: 0;
			box-shadow: 0px -2px 28px 0px rgba(0,0,0,0.06);
		}
	}
</style>
